<template>
    <div>
      <el-dialog title="存入仓库"  :visible.sync="dialogTableVisible">
        <el-form label-width="100px">
          <el-form-item  label="当前的库名">
            <el-input style="width: 200px" readonly :value="wname"></el-input>
          </el-form-item>
          <el-form-item  label="商品名">
            <el-input   style="width: 200px" :value="gname" readonly></el-input>
          </el-form-item>
          <template>
            <el-divider></el-divider>
          </template>
          <el-form-item  label="要存入的库名" >
            <el-input   style="width: 200px" :value="warehouse.waname" readonly></el-input>
          </el-form-item>
          <el-form-item  label="当前库存" >
            <el-input   style="width: 200px" :value="warehouse.amount" readonly></el-input>
          </el-form-item>
          <el-form-item label="可存数量">
            <el-slider input-size="mini" v-model="maxmum" :max="max" :min="1"  show-input></el-slider>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" round style="width: 200px" @click="submitForm('warehousedetails')">提交</el-button>
          </el-form-item>
        </el-form>
      </el-dialog>
    </div>
</template>

<script>
    export default {
      name: "Add_the_warehouse",
      data(){
        return{
          dialogTableVisible: false,
          wname: "",
          gname: "",
          warehouse: {id: "", amount: "", waname: "",mNum:""},//页面显示值
          max:0,
          bid:"",//后端要的数据  b  存放仓库的详情id
          maxmum:1//后端要的数据 要存放的数量
        }
      },
      methods:{
        getda() {
         /* A仓库详情id;
          B仓库详情id;
          要存放的数量;*/
          this.wname = sessionStorage.getItem("Add_the_warehouse_wname");
            this.gname = sessionStorage.getItem("Dispatching_goods_gname");
            let a=parseInt(sessionStorage.getItem("Dispatching_goods_amount"));
            let b=parseInt(this.warehouse.amount);
          if(a+b>this.warehouse.mNum){
            this.max=this.warehouse.mNum-b;
          }else {
            this.max=a;
          }

        },
        submitForm(){
          var params = new URLSearchParams();
          params.append("aid",sessionStorage.getItem("Dispatching_goods_id"));//A仓库详情id
          params.append("bid",this.bid);
          params.append("max",this.maxmum)
          this.$axios.get("warehouseDetailsInfo/warehuseDetailsinfoallocate.action",{params:params}).then(val=>{
            if(val.data.code>0){
              this.$message.success(val.data.msg);
              //关闭模态框
              this.dialogTableVisible=false
              //关闭上一级模态框
              this.$parent.dialogTableVisible=false
              //关闭上上一级模态框
              this.$parent.$parent.dialogTableVisible=false
            }else{
              this.$message.success(val.data.msg);
            }
          }).catch(error=>{
            this.$message.error(error)
          })
        }
      }

    }
</script>

<style scoped>

</style>
